<?php
// 从数据库中读取文件
$p_id = $_REQUEST["p_id"];
$conn = mysqli_connect("localhost:3306","root","","php");
$sql = "select p_image from t_product where p_id = '$p_id'";
$result = mysqli_query($conn, $sql);
if($result){
    if($row = mysqli_fetch_assoc($result)){
        // 告诉浏览器, 返回的数据格式
        header("Content-Type: image");
        echo $row["p_image"];
    } else {
        echo "no data";
    }
}
mysqli_close($conn);
?>